// Includes
#include "LinuxHelpers.h"

#include <time.h>			// Linux time header
#include <sys/utsname.h>		// Linux uname header

#include <cstdio>		// C library standard I/O

namespace EraAstral
{
	// Returns the local time as a string
	std::string GetTimeStr()
	{
		// Return value
		std::string retVal;
		// Character buffer
		char buffer[9];
		
		// Time type returned by time() function
		time_t timeVal;
		// Time structure for formatted time
		tm *timeStruct;
		
		// Get time
		time(&timeVal);
		// Convert to local time
		timeStruct = localtime(&timeVal);
		
		// Print formatted time to buffer
		sprintf(buffer, "%02d:%02d:%02d", timeStruct->tm_hour, timeStruct->tm_min, timeStruct->tm_sec);
		retVal = buffer;
		
		return retVal;
	}

	// Returns the running kernel version as a string
	std::string GetKernelVersion()
	{
		// Temporary system information struct
		struct utsname linuxInfo;
		// Get system information
		uname(&linuxInfo);

		// Return kernel version
		std::string retVal = linuxInfo.release;
		return retVal;
	}
}
